package aash.catalog.views.button;

import aash.catalog.views.component.AashComponent;
import aash.catalog.views.panel.PropertyPanel;
import java.awt.Color;
import java.awt.Graphics;

/**
 * Save button for Explorer View.
 * @author Aashintan
 */
public class SaveButton extends AashButton {
    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = 9072171798433995072L;
    /**
     * Button height.
     */
    private final int height = 40;
    /**
     * Button width.
     */
    private final int width = 120;
    /**
     * Default margin for Y-axis.
     */
    private final int defaultMarginY = 20;
    /**
     * Margin for Y-axis.
     */
    private int marginY;
    /**
     * Label of the button.
     */
    private String name = "";

    /**
     * Class constructor.
     * @param pp property panel
     * @param stName of the button
     */
    public SaveButton(final PropertyPanel pp, final String stName) {
        super();
        name = stName;
        setOpaque(true);
        setBorderPainted(false);
        setFocusPainted(false);
        setContentAreaFilled(false);
        setOpaque(true);
        marginY = defaultMarginY;
        int posX = pp.getX() + (int) (((double) pp.getWidth()) / 2) - (int) (((double) width) / 2);
        int posY = pp.getY() + pp.getHeight() + marginY;
        setBounds(posX, posY, width, height);
    }

    /**
     * Paint method.
     * @param g Graphics
     * @Override JComponent paint
     */
    public final void paint(final Graphics g) {
        Color c = Color.red.brighter().brighter().brighter();
        g.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(),
            (int) (super.getAlpha() * AashComponent.RGB_RANGE)));
        g.fill3DRect(0, 0, width, height, true);
        g.setColor(Color.BLACK);
        g.drawString(name, (int) (((double) width) / 2 - 30), (int) ((((double) height) / 2) + 4));
    }
}
